#-*- encoding:UTF-8 -*-

#vdh_dl,程序运行的对话框部分，Dialog类定义与RunDialog()函数由吴垠编写，保存文件Dialog2()
#函数由张红编写

import wx
import os
import vdh

class Dialog(wx.Dialog):
    def __init__(self, str1, str2):                             #初始化对话框
        wx.Dialog.__init__(self, None, -1, 'Dialog1',
                           size = (400, 200))
        PlayButton = wx.Button(self, wx.ID_OK, "Save", pos = (55, 125))
        PlayButton.SetDefault()
        CloseButton = wx.Button(self, wx.ID_CANCEL, "Cancel", pos = (175, 125))
        DetailText1 = wx.StaticText(self, -1, vdh.str1, pos = (30, 30))
        DetailText2 = wx.StaticText(self, -1, vdh.str2, pos = (200, 30))
        
def RunDialog(n):                                               #运行对话框
    vdh.detail_of_file(n + 1)
    dialog = Dialog(vdh.str1, vdh.str2)
    result = dialog.ShowModal()
    if result == wx.ID_OK:
        Dialog2(n + 1)
    elif result == wx.ID_CANCEL:
        dialog.Destroy()

def Dialog2(n):                                                 #保存文件对话框
    wildcard = "Video File(*.flv)|*.flv|"\
               "Video File(*.f4v)|*.f4v|"\
               "Audio File(*.mp3)|*.mp3|"\
               "All files(*.*)|(*.*)"
    dialog2 = wx.FileDialog(None, "Save your file:", os.getcwd(),
                           "", wildcard, wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
    if dialog2.ShowModal() == wx.ID_OK:
        path = dialog2.GetPath()
        vdh.savevideo(n, path)
    dialog2.Destroy()
    
